import type { SysCompanyDto } from '@/types/Company';
import type { CurrentUserDto } from '@/types/User';

/**
 * @description 保存用户信息
 * @param userInfo
 */
export function setUserInfo(userInfo: CurrentUserDto) {
  localStorage.setItem('userInfo', JSON.stringify(userInfo));
}

/**
 * @description 获取用户信息
 */
export function getUserInfo(): CurrentUserDto | undefined {
  const json = localStorage.getItem('userInfo');
  if (json) {
    return JSON.parse(json);
  }
}

/**
 * @description 获取用户信息
 * @param community
 */
export function setCommunity(community: SysCompanyDto) {
  localStorage.setItem('community', JSON.stringify(community));
}

/**
 * @description 获取社区信息
 */
export function getCommunity(): SysCompanyDto | undefined {
  const json = localStorage.getItem('community');
  if (json) {
    return JSON.parse(json);
  }
}
